package com.demo.web.admin.form;

import java.io.Serializable;

import com.demo.web.admin.form.code.FormRespCode;

public class FormResp implements Serializable{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	private int ecode;
	private String message;
	private Object data;
	private String redirectUri;
	private Integer count;
	
	public static FormResp fail(){
		FormResp formResp = new FormResp();
		formResp.setEcode(FormRespCode.FAIL);
		return formResp;
	}
	
	public static FormResp fail(String message){
		FormResp formResp = new FormResp();
		formResp.setEcode(FormRespCode.FAIL);
		formResp.setMessage(message);
		return formResp;
	}
	
	public static FormResp fail(int code,String message){
		FormResp formResp = new FormResp();
		formResp.setEcode(code);
		formResp.setMessage(message);
		return formResp;
	}
	
	public static FormResp success(){
		FormResp formResp = new FormResp();
		formResp.setEcode(FormRespCode.SUCCESS);
		return formResp;
	}
	
	public static FormResp success(String message){
		FormResp formResp = new FormResp();
		formResp.setEcode(FormRespCode.SUCCESS);
		formResp.setMessage(message);
		return formResp;
	}
	
	public static FormResp success(String message, Object data){
		FormResp formResp = new FormResp();
		formResp.setEcode(FormRespCode.SUCCESS);
		formResp.setData(data);
		formResp.setMessage(message);
		return formResp;
	}
	
	public static FormResp success(Object data){
		FormResp formResp = new FormResp();
		formResp.setEcode(FormRespCode.SUCCESS);
		formResp.setData(data);
		return formResp;
	}
	
	public static FormResp success(Object data, Integer count){
		FormResp formResp = new FormResp();
		formResp.setEcode(FormRespCode.SUCCESS);
		formResp.setData(data);
		formResp.setCount(count);
		return formResp;
	}
	
	public static FormResp noAuthen(){
		FormResp formResp = new FormResp();
		formResp.setEcode(FormRespCode.NO_AUTHEN);
		return formResp;
	}
	
	public String getRedirectUri() {
		return redirectUri;
	}

	public FormResp setRedirectUri(String redirectUri) {
		this.redirectUri = redirectUri;
		return this;
	}

	public FormResp setEcode(FormRespCode formCode) {
		this.ecode = formCode.getCode();
		this.message = formCode.getMessage();
		return this;
	}
	
	public int getEcode() {
		return ecode;
	}
	public FormResp setEcode(int ecode) {
		this.ecode = ecode;
		return this;
	}
	public String getmessage() {
		return message;
	}
	public FormResp setMessage(String message) {
		this.message = message;
		return this;
	}
	public Object getData() {
		return data;
	}
	public FormResp setData(Object data) {
		this.data = data;
		return this;
	}

	public Integer getCount() {
		return count;
	}

	public FormResp setCount(Integer count) {
		this.count = count;
		return this;
	}
}
